﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuickApp.Helpers
{
    public static class IQAParentHelper
    {
        private static void writeXMLStructure(IQAParent parent, int level, StringBuilder sb)
        {
            //TODO: Make work
            //foreach (IQAChild child in parent.Children)
            //{
            //    IQAParent newParent = child as IQAParent;
            //    sb.AppendLine("".PadLeft(level, '\t') + "<" + child.Name + ">");
            //    if (newParent != null)
            //    {
            //        writeXMLStructure(newParent, level + 1,sb);
            //        sb.AppendLine("".PadLeft(level, '\t') + "</" + child.Name + ">");
            //    }
            //}
        }
        
        public static string GetXMLStructure(this IQAParent parent)
        {
            StringBuilder sb = new StringBuilder();
            writeXMLStructure(parent, 0, sb);
            return sb.ToString();
        }

        public static bool HasChildren(this IQAParent parent)
        {
            return !parent.Children.IsNullOrEmpty();
        }
    }
}
